package com.example.video

import android.animation.Animator
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.airbnb.lottie.LottieAnimationView
import com.alibaba.android.arouter.launcher.ARouter
import com.example.video_kotlin_2212a.R
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch


class AppActivity : AppCompatActivity() {
    private lateinit var lottie : LottieAnimationView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_app)

        lottie=findViewById<LottieAnimationView>(R.id.lottieView)

        setupSplashAnimation()


    }

    private fun setupSplashAnimation(){
        lottie.apply {
            setAnimation("loading2.json")

            playAnimation()

            addAnimatorListener(object :android.animation.Animator.AnimatorListener{
                override fun onAnimationStart(p0: Animator) {

                }

                override fun onAnimationEnd(p0: Animator) {
                    ARouter.getInstance().build("/app/MainActivity").navigation()

                    overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out)

                    finish()
                }

                override fun onAnimationCancel(p0: Animator) {

                }

                override fun onAnimationRepeat(p0: Animator) {

                }

            })

        }
    }
}